package com.tencreat.mapper.mall;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tencreat.domain.mall.MallGoodsKill;
import com.tencreat.domain.mall.dto.MallGoodsCollageDTO;
import com.tencreat.domain.mall.dto.MallGoodsRecordDTO;
import com.tencreat.domain.mall.vo.MallGoodsKIllRecordVo;
import com.tencreat.domain.mall.vo.MallGoodsKillVO;
import com.tencreat.domain.mall.vo.ResGoodsKillDetailVO;
import com.tencreat.domain.mall.vo.ResGoodsKillListAppVO;
import com.tencreat.domain.mall.dto.GoodsKillListAppDTO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

/**
 * 商品秒杀Mapper接口
 *
 * @author tencreat
 * @date 2021-09-08
 */
@Repository
public interface MallGoodsKillMapper extends BaseMapper<MallGoodsKill> {

    Page<ResGoodsKillListAppVO> killGoodsListPage(@Param("page") IPage<ResGoodsKillListAppVO> page, @Param("vo") GoodsKillListAppDTO vo, @Param("now") LocalDateTime now);

    ResGoodsKillDetailVO selectMallGoodsKillById(Long id);

    IPage<MallGoodsKillVO> getPCList(IPage<?> page,  @Param("param") MallGoodsCollageDTO dto);

    Map<String, Object> getPCDetails(Long id);

    List<Map<String,Object>> killZoneList();

    /**
     * 锁秒杀数据
     * @param goodsId 商品ID
     * @return 结果
     */
    MallGoodsKill selectForUpdateById(Long goodsId);

    /**
     * 金额统计
     * @param type 1|秒杀成功金额 2|秒杀失败金额
     * @param day 当天时间
     * @return
     */
    BigDecimal killStatistics(@Param("type") Integer type, @Param("day") LocalDateTime day);

    IPage<MallGoodsKIllRecordVo> killRecord(IPage<?> iPage, @Param("param") MallGoodsRecordDTO dto);
}
